ѡļԻ

Sub ѡļ1()'Excel VABWPS VBAVSTOͨãҪãҪؼVB6.0֧

    On Error Resume Next '(Error)룬Զһ

    'һļĶԻ
    Dim filefilter1, filePath As String
    'ļΪjpg bmp pnggif
    filefilter1 = ("ͼƬļ (*.jpg;*.bmp;*.png;*.gif),*.jpg;*.bmp;*.png;*.gif")
   'filefilter1 = ("ļ (*.*),*.*")

    'ûѡļֻܵѡMultiSelect:=True ԶѡMultiSelect:=False ֻѡһļ
    filePath = Application.GetOpenFilename(filefilter1, , "ѡһͼƬļ", , MultiSelect:=False) 'ֻѡһͼƬ

'һVSTOУĳ伴ɡ
 'Dim ExAPP As Excel.Application = Globals.ThisAddIn.Application 'VSTOExcel
 'filePath = ExAPP.GetOpenFilename(filefilter1, , "ѡһͼƬļ", , MultiSelect:=False) 'ֻѡһͼƬ

    MsgBox filePath ,,"ѡļ·+ļ"'ûѡļͷFalseѡļʾļ·
    MsgBox Dir(filePath),,"ѡļ"
    'If filePath = False Then Exit Sub
    If filePath = "" Then Exit Sub
End Sub

**************************************************************************************

Sub ѡļ2() 'Excel VABWPS VBAVB6.0VSTOͨáҪãҪؼ
    
    Dim oDLG
     Set oDLG = CreateObject("MSComDlg.CommonDialog")
     With oDLG
         .DialogTitle = "ļ"
         '.Filter = "ͼƬļ|*.jpg;*.bmp;*.png"
         .Filter = "ļ|*.*"
         .FilterIndex = 1
         .MaxFileSize = 255
         .ShowOpen
         MsgBox .fileName, , "ѡļȫ·+ļ"
         MsgBox Dir(.fileName), , "ѡļļ"
         
         If .fileName <> "" Then
         ' Me.Image1.Picture = LoadPicture(.fileName)
         End If
     End With
     Set oDLG = Nothing

End Sub

Sub ѡļ2()'Excel VABWPS VBAVB6.0VSTOͨáҪãҪؼ
  Dim oDLG
        'Set oDLG = CreateObject("MSComDlg.CommonDialog")'VB6.0VBAдд
        oDLG = CreateObject("MSComDlg.CommonDialog") 'VSTOдд
        With oDLG
            .DialogTitle = "ļ"
            .Filter = "ͼƬļ|*.jpg;*.bmp;*.png"
            '.Filter = "ļ|*.*"
            .FilterIndex = 1
            .MaxFileSize = 255
            .ShowOpen
            MsgBox(.fileName, , "ѡļȫ·+ļ")
            MsgBox(Dir(.fileName), , "ѡļļ")

            If .fileName <> "" Then
                ' Me.Image1.Picture = LoadPicture(.fileName)
            End If
        End With
        'Set oDLG = Nothing 'VB6.0VBAдд
        oDLG = Nothing 'VSTOдд
End Sub
